#include <iostream>

#define ARR_LEN(a)	(sizeof(a) / sizeof(a[0]))

#define MATRIX_SIZE	10
void SparseMatrix(){
	// Waste 97% space
	char m[MATRIX_SIZE][MATRIX_SIZE] = {0};

	m[0][3] = 1;
	m[2][5] = 1;
	m[4][7] = 1;

	// Better, waste 70 space
	char row[MATRIX_SIZE] = {0};
	char col[MATRIX_SIZE] = {0};
	row[0] = 1;
	row[2] = 1;
	row[4] = 1;
	col[3] = 1;
	col[5] = 1;
	col[7] = 1;
}

/*
Possiable Output(Little Endian): 

arr2D1 size = 4 [3] = David
arr2D2 size = 4 [3] = David
0x0031FC0C = 0x12345678
0x0031FC10 = 0x23456789
0x31fc0c = 0x78
0x31fc0d = 0x56
0x0031FC0C = 0x5678
0x0031FC0E = 0x1234
*/
void main()
{
	// NOT GOOD: hardcode length
	char arr2D1[][10] = {"James", "Carl", "Jim", "David"};
	// BETTER
	char* arr2D2[] = {"James", "Carl", "Jim", "David"};

	std::cout << "arr2D1 size = " << ARR_LEN(arr2D1) << " [3] = " << arr2D1[3] << std::endl;
	std::cout << "arr2D2 size = " << ARR_LEN(arr2D2) << " [3] = " << arr2D2[3] << std::endl;

	int int1[] = {0x12345678, 0x23456789};

	std::cout << std::hex << "0x" << (int1) << " = 0x" << *(int1) << std::endl;
	std::cout << std::hex << "0x" << (int1 + 1) << " = 0x" << *(int1 + 1) << std::endl;

	char* char1 = reinterpret_cast<char*>(int1);
	std::cout << std::hex << "0x" << (int)(char1) << " = 0x" << (int)*(char1) << std::endl;
	std::cout << std::hex << "0x" << (int)(char1 + 1) << " = 0x" << (int)*(char1 + 1) << std::endl;

	short int* sint1 = reinterpret_cast<short int*>(int1);
	std::cout << std::hex << "0x" << (sint1) << " = 0x" << *(sint1) << std::endl;
	std::cout << std::hex << "0x" << (sint1 + 1) << " = 0x" << *(sint1 + 1) << std::endl;
}


